package cn.tedu.smartmarketing.user.controller;

import cn.tedu.smartmarketing.base.response.JsonResult;
import cn.tedu.smartmarketing.user.pojo.dto.BehaviorParam;
import cn.tedu.smartmarketing.user.pojo.vo.BehaviorVo;
import cn.tedu.smartmarketing.user.service.BehaviorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/user/behavior")
@Slf4j
public class BehaviorController {
    @Autowired
    BehaviorService behaviorService;
    @PostMapping("record")
    public JsonResult record(BehaviorParam behaviorParam){
        behaviorService.record(behaviorParam);
        return JsonResult.ok();
    }
    @GetMapping("list/{userId}")
    public JsonResult list(@PathVariable Integer userId){
        log.debug("开始处理【用户行为记录】的请求，参数：{}",userId);
        List<BehaviorVo> list = behaviorService.list(userId);
        log.debug("用户行为记录查询结果：{}",list);
        return JsonResult.ok(list);
    }

}
